import { ArticleDetail, Comment } from '@/types/data'
import { ArticleDetailAction } from '@/types/store'

// 初始值
type State = {
   article:ArticleDetail,
   comment:Comment
}

const initState = {
  // 详情
  article: {},
  // 评论
  comment: {}
} as State
export default function articleDetail (state = initState, action:ArticleDetailAction) {
  if (action.type === 'articleDetail/setArticleDetail') {
    return { ...state, article: action.payload }
  } else if (action.type === 'articleDetail/setCommentList') {
    return { ...state, comment: action.payload }
  }
  return state
}
